﻿#region Librerias

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESF.General.MVP;
using ESF.SSO.Core.BusinessLogic;
using ESF.SSO.Core.Entities.BasicReferences;

#endregion


namespace ESF.SSO.Presenter.Admin.Enterprise
{
	public class BrowseEnterprisesPresenter : BaseBrowsePagedPresenter<ESF.SSO.Core.Entities.Enterprise, IBrowseEnterprisesViewer>
	{
		#region Constructor
		
		public BrowseEnterprisesPresenter (IBrowseEnterprisesViewer pViewer) : 
			base (pViewer) {}
		
		#endregion
		
		
		#region Funciones

		public override void Load()
		{
			Browse ();
		}
		
		
		public override void Clear()
		{
			base.Clear ();
			
			_Viewer.IdentificationTypeID = null;
			_Viewer.IdentificationNumber = string.Empty;
			_Viewer.Name = string.Empty;
		}


		protected override ESF.General.Entity.BrowseResults<ESF.SSO.Core.Entities.Enterprise> GetPagedResults(ESF.General.Entity.PaggingInfo pPaggingInfo, out ESF.SSO.Core.Entities.Enterprise pFilter)
		{
			pFilter = new ESF.SSO.Core.Entities.Enterprise ()
			{
				Name = _Viewer.Name,
				IdentificationNumber = _Viewer.IdentificationNumber,
				IdentificationType = new ESF.General.Entity.BasicReference () { ID = _Viewer.IdentificationTypeID }
			};
			
			return CtrlEnterprise.Browse (pFilter, pPaggingInfo);
		}


		public override void Delete(List<ESF.SSO.Core.Entities.Enterprise> pItems)
		{
			CtrlEnterprise.Delete (pItems);
		}
		
		#endregion
	}
}